package cn.bone.admin.system.loginfo.service;

import cn.bone.admin.base.bean.CommonResult;
import cn.bone.admin.base.bean.DataGrid;
import cn.bone.admin.base.bean.ResultFactory;
import cn.bone.admin.system.loginfo.bean.AccessAppLog;
import cn.bone.admin.system.loginfo.dao.IAccessAppLogDao;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by Administrator on 2017/9/12.
 */
@Service
public class AccessService {

    @Resource
    private IAccessAppLogDao accessAppLogDao;

    public CommonResult<DataGrid> queryList(Integer page, Integer rows, String key){

        if(page==null){
            page = 1;
        }
        if(rows==null){
            rows = 10;
        }
        int start = (page-1)*rows;
        List<AccessAppLog> accessAppLogs = accessAppLogDao.queryList(start, rows, key);
        int count = accessAppLogDao.countQueryList(key);

        DataGrid<AccessAppLog> dataGrid = DataGrid.dataGrid(accessAppLogs, count, page, rows);
        return ResultFactory.ok(dataGrid);
    }
}
